'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-10-27 09:40:43
'''
#
# @lc app=leetcode.cn id=144 lang=python3
#
# [144] 二叉树的前序遍历
#

# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def preorderTraversal(self, root: TreeNode) -> List[int]:
        ans = []
        def recurse(root):
            if not root:
                return
            ans.append(root.val)
            recurse(root.left)
            recurse(root.right)
        recurse(root)
        return ans
        
# @lc code=end

